import 'package:ncov_2019/beans/Entity.dart';
import 'package:ncov_2019/commom/check.dart';
import 'package:ncov_2019/http/view_model.dart';
import 'package:shared_preferences/shared_preferences.dart';

EntityViewModel entityViewModel = new EntityViewModel();

class EntityViewModel extends ViewModel {
  /*
  * 按时间线获取事件
  * */
  Future<dynamic> getEntityNews() async {
    SharedPreferences sp = await SharedPreferences.getInstance();
    String uuid = sp.getString("uuid");
    if(uuid==null){

    }else{
    final Map map = await EntityReqModel().data(uuid);
    List list = new List();
    if (map != null && map.isNotEmpty) {
      final data = map['result']['app_esp_ip'];
      if (listNoEmpty(data)) {
        data.forEach((json) => list.add(App_esp_ip.fromJson(json)));
      }
    }
    return Future.value(list);
    }
  }
}
